/**
 * date: 2018年2月20日
 * 使用'Visual Studio Code 1.18.1'编写
 * ctrl + shift + P
 * ctrl + shift + L
 * 
 * from https://www.tslang.cn/docs/handbook/typescript-in-5-minutes.html
 * `cnpm install -g typescript` : 要运行ts文件需要安装
 * 
 */

function greeter(person: string) {
    return "Hello, " + person;
}

let user = "Jane User"; // [0,1,2]; //"Jane User";

document.body.innerHTML = greeter(user);

interface Person {
    firstName: string;
    lastName: string;
}

function greeter2(person: Person) {
    return "Hello, " + person.firstName + ", " + person.lastName;
}

let user2 = {firstName: "Jane", lastName: "User"};

document.body.innerHTML = greeter2(user2);

class Student {
    fullName: string;
    constructor(public firstName, public middleInitial, public lastName) {
        this.fullName = firstName + " " + middleInitial + " " + lastName;
    }
}

interface Person3 {
    firstName:string;
    lastName:string;
}
function greeter3(person: Person3){
    return "Hello, " + person.firstName + " " + person.lastName;
}
let user3 = new Student("Jane", "M.", "User");
document.body.innerHTML = greeter3(user3);

